package com.qf.lanzhou.shop.admin.service.impl;

import com.qf.lanzhou.shop.admin.dao.PageAdminMapper;
import com.qf.lanzhou.shop.admin.service.PageAdminService;
import com.qf.lanzhou.shop.pojo.entity.Goods;
import com.qf.lanzhou.shop.pojo.entity.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Yeach-chen
 * @ClassName PageAdminServiceImpl
 */
@Service
public class PageAdminServiceImpl implements PageAdminService {
    @Autowired
    private PageAdminMapper pageAdminMapper;
    @Override
    public List<Goods> getGoodsShow(Integer pageIndex) {
        Page page = new Page(pageIndex);
        List<Goods> goods = pageAdminMapper.selectAllGoods(page);
        return goods;
    }

    @Override
    public int getCount() {
        int sum = pageAdminMapper.selectCount();
        if (sum%8>0){
            return (sum/8)+1;
        }
        return sum/8;
    }
}
